//
//  ViewBezier.m
//  核心动画
//
//  Created by chichaojituan521 on 2017/5/31.
//  Copyright © 2017年 linch. All rights reserved.
//

#import "ViewBezier.h"

@implementation ViewBezier


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    UIColor *color = [UIColor redColor];
    [color set]; //设置线条颜色
    
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(10, 100)];
    [path addLineToPoint:CGPointMake(200, 200)];
    
    path.lineWidth = 5.0;
    path.lineCapStyle = kCGLineCapRound; //线条拐角
    path.lineJoinStyle = kCGLineJoinRound; //终点处理
    
    [path stroke];
    
    
    [path moveToPoint:CGPointMake(300.0, 80.0)];//起点
    
    // Draw the lines
    [path addLineToPoint:CGPointMake(400.0, 150.0)];
    [path addLineToPoint:CGPointMake(320, 200)];
    [path addLineToPoint:CGPointMake(250.0, 180)];
    [path addLineToPoint:CGPointMake(200, 130.0)];
    [path closePath];//第五条线通过调用closePath方法得到的
    
        [path stroke];//Draws line 根据坐标点连线
//    [path fill];//颜色填充
    
//    二次贝赛尔曲线
    [path moveToPoint:CGPointMake(40, 350)];
    [path addQuadCurveToPoint:CGPointMake(140, 380) controlPoint:CGPointMake(200, 80)];
    [path stroke];
    
//    三次贝赛尔曲线
    [path moveToPoint:CGPointMake(40, 550)];
    [path addCurveToPoint:CGPointMake(300, 500) controlPoint1:CGPointMake(100, 200) controlPoint2:CGPointMake(200, 600)];
    [path stroke];
    
    
}


@end
